package com.sl.biz.modular.ai.dao.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sl.biz.modular.ai.dao.domain.entity.AiChatConfigDO;
import com.sl.biz.modular.ai.dao.mapper.AiChatConfigMapper;
import com.sl.biz.modular.ai.dao.service.AiChatConfigDaoService;
import org.springframework.stereotype.Service;


@Service
public class AiChatConfigDaoServiceImpl extends ServiceImpl<AiChatConfigMapper, AiChatConfigDO> implements AiChatConfigDaoService {


    @Override
    public Boolean removeByAiId(String aiId) {
        LambdaQueryWrapper<AiChatConfigDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(AiChatConfigDO::getAiId, aiId);
        return super.remove(lambdaQueryWrapper);
    }

    @Override
    public AiChatConfigDO getByAiId(String aiId) {
        LambdaQueryWrapper<AiChatConfigDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(AiChatConfigDO::getAiId, aiId);
        return CollUtil.get(super.list(lambdaQueryWrapper), 0);
    }
}
